package com.shujia.java.day17.demo1;

import java.io.FileInputStream;

public class Demo1 {
    public static void main(String[] args) throws Exception {
        //创建输入流
        FileInputStream fis = new FileInputStream("test2.txt");
        //读取数据
        //1.一个一个读
//        int i = 0;
//        while ((i = fis.read()) != -1) {
//            System.out.print((char) i);
//        }
        //2.一次读一个数组
        byte[] bytes = new byte[5];
        int i;
        while ((i = fis.read(bytes)) != -1) {
            System.out.print(new String(bytes,0,i));
        }

        //关闭流
        fis.close();
    }
}
